
# Comment/uncomment the following line to enable/disable debugging
#DEBUG = y


ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DSCULLP_DEBUG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

dev_ctl_kernel-OBJECTS = ../../dev_ctl_kernel/net_link_io.o 
common-OBJECTS = ../../common/xobject.o ../../common/hashtb.o 

main-OBJECTS = main.o sm3.o \
			   policy_buffer.o \
			   file_misc.o file_access.o \
			   lsm.o ioctl.o \
			   init.o file_table.o \
			   file_ctx.o file_mon.o \
			   globals.o audit_list.o \
			   config.o 
  

#CFLAGS += $(DEBFLAGS) -I$(LDDINC) -I"../misc/"
VPATH = .:../misc

total-OBJECTS = $(main-OBJECTS) $(dev_ctl_kernel-OBJECTS) $(common-OBJECTS)

EXTRA_CFLAGS += -I$(INC) -I$(SELF_PATH) 

TARGET = os_sec_mod.ko

ifneq ($(KERNELRELEASE),)

os_sec_mod-objs := $(total-OBJECTS)
obj-m	:= os_sec_mod.o
# obj-m 制定最后模块的名字？
else

#添加相应的头文件目录
PRIVATE_INC = $(shell pwd)/../include 
__SELF = $(shell pwd)/
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

modules:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) INC=$(PRIVATE_INC) SELF_PATH=$(__SELF) modules

# M=$(PWD) : 指定模块编译之后的路径,同时也指定了内核的MAKEFILE第二次再次调用本MAKEFILE;
# INC=$(PRIVATE_INC) ：通知内核的MAKEFILE定义一个INC变量，初始值为$(PRIVATE_INC)，
# PRIVATE_INC不能够直接传给内核MAKEFILE给第二次经过这个文件的时候用；
#

endif


install:
	install -d $(INSTALLDIR)
	install -c $(TARGET).o $(INSTALLDIR)

clean:
	rm -rf *.o $(total-OBJECTS) *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions modules.order  Module.symvers


depend .depend dep:
	$(CC) $(CFLAGS) -M *.c > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
